package tour.spring.bc.assembler;

import java.util.ArrayList;
import java.util.Collection;

import org.springframework.stereotype.Component;

import tour.spring.bc.dto.RegionDto;
import tour.spring.bc.model.Region;

@Component
public class RegionAssembler2 {
	public RegionDto convertToDto(Region region) {
		RegionDto regionDto = new RegionDto();
		regionDto.setId(region.getId());
		regionDto.setCountryName(region.getCountry().getName());
		regionDto.setName(region.getName());
		return regionDto;
	}
	
	public Collection<RegionDto> convertToDto(Collection<Region> regions) {
		ArrayList<RegionDto> list = new ArrayList<RegionDto>(); 
		for (Region region : regions) {
			list.add(convertToDto(region));
		}
		return list;
	}
}
